package com.wrb.appointment.feign;

import com.wrb.appointment.model.Customer;
import com.wrb.appointment.response.ServerResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author Wrb
 * @date 2019/12/20 16:21
 */
@FeignClient(name = "summary-customer",fallback = CustomerServiceFeign.CustomerServiceFeignHystrix.class)
public interface CustomerServiceFeign {

	@RequestMapping(value = "/micro/customer/get", method = RequestMethod.POST)
	ServerResponse get(
			@RequestParam(required = true) long customerId
	);

	@Component
	@Slf4j
	class CustomerServiceFeignHystrix implements CustomerServiceFeign{

		@Override
		public ServerResponse<Customer> get(long customerId) {
			log.error("查询用户信息超时");
			return null;
		}
	}
}
